package com.ming.luckyDemo.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    public String getCurrentTime() {
        // 格式化时间
        SimpleDateFormat sdf = new SimpleDateFormat();
        sdf.applyPattern("yyy-MM-dd HH:mm:ss");
        //获取当前时间
        Date date = new Date();
        return sdf.format(date);
    }
    public int getNumbers(){
        DateUtil dateUtil = new DateUtil();
        String a = dateUtil.getCurrentTime().substring(5, 7);
        String b = dateUtil.getCurrentTime().substring(8, 10);
        String c = dateUtil.getCurrentTime().substring(11, 13);
        String d = dateUtil.getCurrentTime().substring(14, 16);
        String number = a+b+c+d;
        int i = Integer.parseInt(number);
        return i;
    }
    public int getSecond() {
        DateUtil dateUtil = new DateUtil();
        int length = dateUtil.getCurrentTime().length();
        String s = dateUtil.getCurrentTime().substring(length - 2);
        return Integer.parseInt(s);
    }
}
